import * as types from '../actions/mainScreenActionTypes';
import testinitDate from './TestinitDate';//这个是默认的测试数据
import TimerMixin from 'react-timer-mixin';

const initialState=testinitDate;

export default function mainscreenRedux(state = initialState, action = {}) {
  switch (action.type) {
    //选择猪场
    case types.SELECTFARM:
      return {
        ...state,
        mainscreen:{
          ...state.mainscreen,
          title:state.mainscreen.farmlistDetail[action.index]
        }
      };
    //listview滚动到特定的section时改变
    case types.CHANGEFARMUNIT:
      return {
        ...state,
        mainscreen:{
          ...state.mainscreen,
          farmunit:action.farmunitname
        }
      };
    //单击bwlist的时候
    case types.ENTER_FARM_UNIT:
      return {
        ...state,
        bwmain:{
          ...state.bwmain,
          currentUnit:state.mainscreen.title+'/'+action.currentSec,
          currentAddr:action.currentAddr
        }
      };
    default:
      return state;
  }
}
